# coding: utf-8
from fastapi import FastAPI
import sock

app = FastAPI()


@app.get("/get/{no}")
def test_get(no: int):
    """this is a test function"""
    return no


@app.get("/calc/{calc_str}")
def test_get(calc_str: str):
    """this is a test function"""
    try:
        return eval(calc_str)
    except Exception as e:
        return "wrong!"


try:
    a = 1
except Exception:  # 捕获的异常范围太大
    pass

ip = "127.0.0.1"
sock = socket.socket()
sock.bind((ip, 9090))

if __name__ == "__main__":
    app.run(port=9560)